url="C:/Users/rohit/Desktop/CS Courses/DPA/Project/Crimes_-_2001_to_present.csv"
testurl="C:/Users/rohit/Desktop/CS Courses/DPA/Project/Crimes_2017_Test.csv"
df <- data.frame(read.csv(file=url, header=TRUE, sep=","))
testdf <- data.frame(read.csv(file=testurl, header=TRUE, sep=","))
sprintf("Number of Rows in Dataframe: %s", format(nrow(df),big.mark = ","))
[1] "Number of Rows in Dataframe: 268,482"
df <- subset(df, select = -c(Case.Number, Block, IUCR,Beat,District,Ward,Community.Area,X.Coordinate,Y.Coordinate,FBI.Code,Updated.On))
testdf <- subset(testdf, select = -c(Case.Number, Block, IUCR,Beat,District,Ward,Community.Area,X.Coordinate,Y.Coordinate,FBI.Code,Updated.On))
head(df)
write.csv(df,"format.csv", row.names = FALSE)
library(lubridate)
# Create a variable count with value 1
df$Count <- 1
testdf$Count <- 1
# Convert Date from factor to date
df$Date <- mdy_hms(df$Date)
testdf$Date <- mdy_hms(testdf$Date)
# Extract hour from Date
df$Hour <- substring(df$Date, 12,13)
testdf$Hour <- substring(testdf$Date, 12,13)
# Drop time from Date
df$Date <- as.Date(df$Date, format="%m/%d/%Y")
testdf$Date <- as.Date(testdf$Date, format="%m/%d/%Y")
write.csv(df,"format.csv", row.names = FALSE)
aa = table(rowSums(is.na(df)))
aa
0 2
266532 1950
#Remove all NA
df <- df[complete.cases(df),]
testdf <- testdf[complete.cases(testdf),]
head(df)
###Visualizations
library(ggplot2)
library(ggrepel)
df_loc <- sort(table(df$Location.Description),decreasing = TRUE)
df_loc <- data.frame(df_loc[df_loc > 10000])
colnames(df_loc) <- c("Location", "Frequency")
df_loc$Percentage <- df_loc$Frequency / sum(df_loc$Frequency)
df_loc
lp<-ggplot(df_loc, aes(x=Location, y=Frequency, fill=Location)) + geom_bar(stat="identity") +
theme(axis.text.x=element_blank()) + geom_text_repel(data=df_loc, aes(label=Location))
lp
library(ggplot2)
library(ggrepel)
df_category <- sort(table(df$Primary.Type),decreasing = TRUE)
df_category <- data.frame(df_category[df_category > 10000])
colnames(df_category) <- c("Category", "Frequency")
df_category$Percentage <- df_category$Frequency / sum(df_category$Frequency)
df_category
bp<-ggplot(df_category, aes(x=Category, y=Frequency, fill=Category)) + geom_bar(stat="identity") +
theme(axis.text.x=element_blank()) + geom_text_repel(data=df_category, aes(label=Category))
bp
bp<-ggplot(df_category, aes(x="", y=Percentage, fill=Category)) + geom_bar(stat="identity")
pie <- bp + coord_polar("y")
pie
###Integrating With Map
library(ggmap)
#library(dmm)
register_google(key = 'AIzaSyAtlORy7YG5gJ9GA52crQgHJqmz_2xYeEM')
#get the map of LA
Chi_map <- qmap(location = "Chicago", zoom = 12)
Source : https://maps.googleapis.com/maps/api/staticmap?center=Chicago&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
Source : https://maps.googleapis.com/maps/api/geocode/json?address=Chicago&key=xxx
Chi_map
#unfactor variable
#df$Latitude <- unfactor(df$Latitude)
#df$Longitude <- unfactor(df$Longitude)
####HeatMaps
library(dplyr)
Attaching package: <U+393C><U+3E31>dplyr<U+393C><U+3E32>
The following objects are masked from <U+393C><U+3E31>package:lubridate<U+393C><U+3E32>:
intersect, setdiff, union
The following objects are masked from <U+393C><U+3E31>package:stats<U+393C><U+3E32>:
filter, lag
The following objects are masked from <U+393C><U+3E31>package:base<U+393C><U+3E32>:
intersect, setdiff, setequal, union
#select relevant variables
mapping <- df %>% select(Primary.Type, Longitude, Latitude) %>% filter(Primary.Type == 'THEFT') %>%
na.omit()
Chi_map + geom_density_2d(aes(x = Longitude, y = Latitude), data = mapping) +
stat_density2d(data = mapping,
aes(x = Longitude, y = Latitude, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red",
guide = FALSE) + scale_alpha(range = c(0, 0.3), guide = FALSE)
mapping <- df %>% select(Primary.Type, Longitude, Latitude) %>% filter(Primary.Type == 'MOTOR VEHICLE THEFT') %>%
na.omit()
Chi_map + geom_density_2d(aes(x = Longitude, y = Latitude), data = mapping) +
stat_density2d(data = mapping,
aes(x = Longitude, y = Latitude, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red",
guide = FALSE) + scale_alpha(range = c(0, 0.3), guide = FALSE)
###Predict Crime Spots
library(leaflet)
data <- df[1:10000,] # display the first 10,000 rows
data$popup <- paste("<b>Category: </b>", data$Category,
"<br>", "<b>Description: </b>", data$Primary.Type,
"<br>", "<b>Description: </b>", data$Description,
"<br>", "<b>Date: </b>", data$Date,
"<br>", "<b>Time: </b>", data$Hour,
"<br>", "<b>Arrest?: </b>", data$Arrest,
"<br>", "<b>Longitude: </b>", data$Longitude,
"<br>", "<b>Latitude: </b>", data$Latitude)
leaflet(data, width = "100%") %>% addTiles() %>%
addTiles(group = "OSM (default)") %>%
addProviderTiles(provider = "Esri.WorldStreetMap",group = "World StreetMap") %>%
addProviderTiles(provider = "Esri.WorldImagery",group = "World Imagery") %>%
# addProviderTiles(provider = "NASAGIBS.ViirsEarthAtNight2012",group = "Nighttime Imagery") %>%
addMarkers(lng = ~Longitude, lat = ~Latitude, popup = data$popup, clusterOptions = markerClusterOptions()) %>%
addLayersControl(
baseGroups = c("OSM (default)","World StreetMap", "World Imagery"),
options = layersControlOptions(collapsed = FALSE)
)
###Clustering Analysis
library(fields)
package <U+393C><U+3E31>fields<U+393C><U+3E32> was built under R version 3.5.3Loading required package: spam
package <U+393C><U+3E31>spam<U+393C><U+3E32> was built under R version 3.5.3Loading required package: dotCall64
package <U+393C><U+3E31>dotCall64<U+393C><U+3E32> was built under R version 3.5.3Loading required package: grid
Spam version 2.4-0 (2019-11-01) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
Attaching package: <U+393C><U+3E31>spam<U+393C><U+3E32>
The following object is masked from <U+393C><U+3E31>package:Matrix<U+393C><U+3E32>:
det
The following objects are masked from <U+393C><U+3E31>package:base<U+393C><U+3E32>:
backsolve, forwardsolve
Loading required package: maps
package <U+393C><U+3E31>maps<U+393C><U+3E32> was built under R version 3.5.3See https://github.com/NCAR/Fields for
an extensive vignette, other supplements and source code
lon = df$Longitude[1:1000]
lat = df$Latitude[1:1000]
threshold.in.km <- 40
coors <- data.frame(lon,lat)
testlon = testdf$Longitude[1:600]
testlat = testdf$Latitude[1:600]
threshold.in.km <- 40
testcoors <- data.frame(testlon,testlat)
#distance matrix
dist.in.km.matrix <- rdist.earth(coors,miles = F,R=6371)
#clustering
fit <- hclust(as.dist(dist.in.km.matrix), method = "single")
clusters <- cutree(fit,h = threshold.in.km)
str(fit)
List of 7
$ merge : int [1:999, 1:2] -7 -11 -47 -99 -118 -132 -147 -927 -162 -621 ...
$ height : num [1:999] 0 0 0 0 0 0 0 0 0 0 ...
$ order : int [1:1000] 638 790 197 523 110 192 359 27 454 804 ...
$ labels : NULL
$ method : chr "single"
$ call : language hclust(d = as.dist(dist.in.km.matrix), method = "single")
$ dist.method: NULL
- attr(*, "class")= chr "hclust"
plot(lon, lat, col = clusters, pch = 20)
#Theft <- df %>% select(Primary.Type, Longitude, Latitude) %>% filter(Primary.Type == 'THEFT') %>%
# na.omit()
#lon1 = Theft$Longitude[1:500]
#lat1 = Theft$Latitude[1:500]
#coors <- data.frame(lon1,lat1)
library(geosphere)
package <U+393C><U+3E31>geosphere<U+393C><U+3E32> was built under R version 3.5.3
library(ggmap)
library(NbClust)
geo.dist = function(df) {
require(geosphere)
d <- function(i,z){ # z[1:2] contain long, lat
dist <- rep(0,nrow(z))
dist[i:nrow(z)] <- distHaversine(z[i:nrow(z),1:2],z[i,1:2])
return(dist)
}
dm <- do.call(cbind,lapply(1:nrow(df),d,df))
return(as.dist(dm))
}
k<-list()
betweenSSByTotalSS <- list()
for(i in 1:6){
k[[i]] <- kmeans(coors,i)
}
for(i in 1:6){
betweenSSByTotalSS[[i]]<-k[[i]]$betweenss/k[[i]]$totss
}
plot(1:6,betweenSSByTotalSS,type="b",ylab="Between SS by Total SS",xlab="Clusters(k)")
km <- kmeans(geo.dist(coors),centers=2)
coors$Borough <- as.factor(km$cluster)
Chi_map <- get_map(location = "Chicago", zoom = 10)
Source : https://maps.googleapis.com/maps/api/staticmap?center=Chicago&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
Source : https://maps.googleapis.com/maps/api/geocode/json?address=Chicago&key=xxx
pqr = ggmap(Chi_map) + geom_point(aes(x = coors$lon, y = coors$lat, colour = as.factor(Borough)),data = coors)
plot(pqr)
testcoors <- testcoors %>% na.omit()
testkm <- kmeans(geo.dist(testcoors),centers=2)
testcoors$Borough <- as.factor(testkm$cluster)
Chi_map <- get_map(location = "Chicago", zoom = 10)
Source : https://maps.googleapis.com/maps/api/staticmap?center=Chicago&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
Source : https://maps.googleapis.com/maps/api/geocode/json?address=Chicago&key=xxx
testpqr = ggmap(Chi_map) + geom_point(aes(x = testcoors$testlon, y = testcoors$testlat, colour = as.factor(Borough)),data = testcoors)
plot(testpqr)
#print(km['size'])
#print(km$totss)
print(km)
K-means clustering with 2 clusters of sizes 546, 454
Cluster means:
1 2 3 4 5 6 7 8 9 10 11
1 17516.311 16231.58 15187.891 7002.47 9513.037 11607.319 5735.451 6603.373 7681.609 23617.841 16217.892
12 13 14 15 16 17 18 19 20 21 22
1 18466.45 14937.765 6405.88 6687.519 19099.571 17007.228 20342.30 6404.69 28163.28 18739.499 9276.959
23 24 25 26 27 28 29 30 31 32 33
1 7298.619 8270.427 15244.442 6454.109 29606.28 7208.502 5971.12 5823.067 18648.847 7534 15029.861
34 35 36 37 38 39 40 41 42 43 44
1 10282.53 6641.103 5947.783 22610.153 6484.557 24977.291 14858.1 11607.499 21983.94 6404.69 15440.840
45 46 47 48 49 50 51 52 53 54 55
1 7820.498 15644.391 10769.74 8178.882 15965.41 15109.099 13435.464 10918.05 6618.546 9018.031 10844.14
56 57 58 59 60 61 62 63 64 65 66
1 19113.012 25554.14 6109.051 7486.084 8039.717 8010.979 5961.075 16397.410 24502.474 10769.74 13391.275
67 68 69 70 71 72 73 74 75 76 77
1 5753.904 19036.92 7379.17 8142.97 8652.414 16217.892 12707.122 6229.526 8888.839 18842.58 5916.162
78 79 80 81 82 83 84 85 86 87 88
1 8060.234 8106.22 19735.57 7420.036 13310.10 16298.441 24712.920 6915.95 6983.761 16995.65 13124.296
89 90 91 92 93 94 95 96 97 98 99
1 7055.236 6533.162 19650.957 10083.99 7552.252 7015.627 13731.02 18844.859 18931.809 7116.728 7342.925
100 101 102 103 104 105 106 107 108 109 110
1 23590.316 18712.835 7326.925 7800.8 7763.822 7625.878 19333.129 7270.552 12548.889 14546.372 28099.33
111 112 113 114 115 116 117 118 119 120
1 16512.943 15547.166 7323.097 20633.596 7696.778 7845.244 6542.535 7175.095 12537.601 6061.056
121 122 123 124 125 126 127 128 129 130 131
1 7123.789 24620.197 8191.611 15887.361 6247.373 19834.254 7981.411 10630.08 10988.89 24780.559 19629.833
132 133 134 135 136 137 138 139 140 141 142
1 7311.753 5859.156 24825.01 12837.07 26059.07 8424.052 15445.933 6801.334 13168.74 6909.783 22013.829
143 144 145 146 147 148 149 150 151 152 153
1 8861.942 6257.72 8301.355 17735.915 6490.817 7461.011 14559.892 25243.723 7036.604 6699.625 7742.975
154 155 156 157 158 159 160 161 162 163 164
1 27551.71 15663.278 7402.287 5839.752 19449.48 8568.535 8606.161 7692.138 19103.60 7290.951 8374.405
165 166 167 168 169 170 171 172 173 174
1 19841.373 6757.799 5896.514 9102.602 7023.696 12291.846 22458.250 14721.582 5846.725 21076.294
175 176 177 178 179 180 181 182 183 184 185
1 7601.643 25667.10 20437.257 23532.970 12387.456 12542.85 10244.16 6447.484 17079.736 7971.073 15009.028
186 187 188 189 190 191 192 193 194 195 196
1 6324.023 6069.986 7921.867 15949.520 8024.132 5934.088 27545.52 12411.99 23036.966 13870.495 5923.257
197 198 199 200 201 202 203 204 205 206 207
1 16665.62 6958.41 6942.164 6486.357 6179.774 5742.045 13051.99 5898.161 20086.227 11080.41 18548.361
208 209 210 211 212 213 214 215 216 217 218
1 8060.934 8735.073 6577.627 6962.632 5935.961 20942.87 8982.201 6500.421 21706.106 23613.89 13674.79
219 220 221 222 223 224 225 226 227 228 229
1 14509.42 7310.834 7175.095 7311.753 8298.964 8170.149 25607.513 6282.352 7815.457 6292.308 16504.264
230 231 232 233 234 235 236 237 238 239 240
1 8022.873 19843.279 23850.329 23912.745 7565.847 17777.98 18214.455 7407.751 8148.723 7565.847 7997.723
241 242 243 244 245 246 247 248 249 250 251
1 7363.943 22864.533 7895.131 5887.592 15959.171 6938.159 13559.917 8404.047 6372.80 7750.137 26396.27
252 253 254 255 256 257 258 259 260 261 262
1 6070.021 15314.41 7142.036 6854.954 8062.719 7843.606 7546.521 7896.491 7473.215 11791.91 19370.65
263 264 265 266 267 268 269 270 271 272
1 5736.246 7141.142 8300.903 8142.535 7516.612 6292.308 22690.013 19213.718 17232.801 8012.256
273 274 275 276 277 278 279 280 281 282 283
1 6955.461 5765.834 15583.83 7754.413 19336.500 7692.322 11797.863 7310.309 6287.96 7217.01 8481.047
284 285 286 287 288 289 290 291 292 293 294
1 23498.460 16338.03 7961.522 7343.942 15623.004 12713.071 7536.808 10323.25 6337.616 7065.07 10415.103
295 296 297 298 299 300 301 302 303 304 305
1 26108.107 6802.657 8332.226 17097.962 17097.962 9697.048 7167.163 15751.037 18503.328 19116.76 25150.525
306 307 308 309 310 311 312 313 314 315 316
1 9561.47 5812.013 25638.420 7317.591 7498.203 15999.503 6317.417 5795.20 22176.633 12779.86 7826.331
317 318 319 320 321 322 323 324 325 326 327
1 13622.451 6509.531 16447.303 20914.407 16812.839 7644.913 8140.331 7816.953 19480.749 16817.426 6893.96
328 329 330 331 332 333 334 335 336 337 338
1 7844.056 6517.292 8488.552 7913.134 7543.829 17202.623 6253.863 19781.024 8811.422 6405.197 10051.67
339 340 341 342 343 344 345 346 347 348 349
1 13931.700 6295.239 18372.65 15824.828 11791.91 17930.178 19257.994 13593.396 7050.768 8205.566 18320.824
350 351 352 353 354 355 356 357 358 359 360
1 6092.697 13874.52 8359.70 28087.37 18993.799 13253.005 20007.551 8777.08 7633.72 29495.80 19556.48
361 362 363 364 365 366 367 368 369 370 371
1 16784.772 23326.666 12895.65 8123.366 7559.473 7732.267 16141.47 5895.846 17805.135 7129.902 15023.477
372 373 374 375 376 377 378 379 380 381 382
1 7371.098 7058.88 9971.966 7971.11 6195.518 7297.699 22691.213 7992.016 8619.005 8619.005 8671.188
383 384 385 386 387 388 389 390 391 392 393
1 17951.139 20973.496 6297.41 6612.906 15393.390 6053.175 21100.685 5942.593 9781.797 13874.52 16604.820
394 395 396 397 398 399 400 401 402 403 404
1 7283.873 15021.760 10681.50 11125.469 18525.065 18404.70 9818.38 6079.799 7986.352 7986.352 20536.342
405 406 407 408 409 410 411 412 413 414 415
1 7216.415 7750.137 6163.307 15196.972 14206.418 8313.781 14580.049 17953.746 6184.024 18606.36 24602.934
416 417 418 419 420 421 422 423 424 425 426
1 26072.62 7662.079 7908.579 6525.268 22266.622 8231.851 7691.308 12228.350 21742.283 9392.476 20070.609
427 428 429 430 431 432 433 434 435 436
1 9473.079 7378.764 9832.253 16347.341 8514.116 8040.082 7782.712 6525.268 9075.526 25539.422
437 438 439 440 441 442 443 444 445 446 447
1 7826.992 20715.809 8655.108 7496.597 14578.958 6239.143 7916.509 14737.480 7895.514 17092.946 18372.65
448 449 450 451 452 453 454 455 456 457 458
1 25569.080 11693.758 21153.487 7795.208 19908.451 26109.50 29794.96 7027.046 6649.857 19511.456 7628.715
459 460 461 462 463 464 465 466 467 468 469
1 7628.715 5922.583 21924.075 14277.214 16935.693 18827.49 10193.29 6863.965 18449.434 7345.002 14835.79
470 471 472 473 474 475 476 477 478 479
1 9806.895 8142.472 17632.932 7159.279 17171.053 22833.899 25164.526 23594.008 7019.588 7666.288
480 481 482 483 484 485 486 487 488 489 490
1 13386.946 16335.533 7761.092 18555.782 28402.33 22921.189 18582.959 23378.959 7548.553 12878.55 10305.90
491 492 493 494 495 496 497 498 499 500
1 8551.875 15961.180 7795.208 18427.277 17342.827 20335.653 22747.763 7157.009 22502.171 20418.809
501 502 503 504 505 506 507 508 509 510 511
1 12191.141 14638.648 22111.239 7156.196 6685.335 7498.843 5746.296 8293.998 8596.691 11475.53 6169.534
512 513 514 515 516 517 518 519 520 521 522
1 18557.878 19103.60 7497.56 8071.721 16374.378 7007.281 6981.507 9069.543 24284.217 21479.843 7905.091
523 524 525 526 527 528 529 530 531 532 533
1 15796.21 11446.980 21236.222 26694.119 7896.713 7582.436 19231.665 14652.44 9772.382 7748.407 13658.1
534 535 536 537 538 539 540 541 542 543 544
1 8195.256 7455.612 17041.803 6018.978 21681.242 18985.45 17939.983 6941.139 14578.958 11435.470 23930.430
545 546 547 548 549 550 551 552 553 554 555
1 10362.36 7146.057 27352.86 7980.664 15837.453 21797.526 18801.461 7825.457 7691.308 7143.214 6923.566
556 557 558 559 560 561 562 563 564 565 566
1 8645.399 7150.803 13802.378 18781.159 7184.432 16809.931 5743.607 7750.137 19489.87 7157.009 12171.07
567 568 569 570 571 572 573 574 575 576 577
1 10528.85 7717.605 6110.936 15547.07 11363.480 7081.253 25069.02 8858.035 6695.966 7632.191 6085.67
578 579 580 581 582 583 584 585 586 587 588
1 7001.948 17821.310 8240.454 15968.548 6608.002 24928.474 21437.636 14808.96 14392.738 6284.63 7388.006
589 590 591 592 593 594 595 596 597 598
1 7567.932 6150.365 14061.946 19684.669 6259.236 12468.783 21606.806 7539.317 20676.829 19826.310
599 600 601 602 603 604 605 606 607 608 609
1 7159.564 19957.591 18721.227 17002.852 7015.93 7895.514 7864.472 6829.177 9366.046 6989.284 18854.776
610 611 612 613 614 615 616 617 618 619 620
1 22218.931 12059.62 14623.343 7157.009 18827.49 23957.960 14132.805 20020.326 5823.165 15312.391 7813.747
621 622 623 624 625 626 627 628 629 630 631
1 19103.60 19846.985 17363.013 11883.406 12335.217 16512.098 20249.91 15154.998 7546.42 24112.036 12472.230
632 633 634 635 636 637 638 639 640 641 642
1 8442.627 18770.850 21165.121 7596.557 21585.217 6439.903 30656.67 10327.45 8056.32 13093.82 6092.578
643 644 645 646 647 648 649 650 651 652 653
1 6212.818 10648.84 22960.770 18263.304 8113.15 13938.467 12807.353 7004.615 11883.406 7884.64 6665.086
654 655 656 657 658 659 660 661 662 663 664
1 21599.145 16275.438 7740.971 6590.603 16596.883 17305.201 6322.031 19594.395 21498.24 6918.383 13929.22
665 666 667 668 669 670 671 672 673 674 675
1 9058.65 6380.729 26716.067 6885.164 19311.925 7635.409 10550.86 22607.253 7286.226 14680.250 7938.704
676 677 678 679 680 681 682 683 684 685
1 18545.313 7376.895 9505.696 20670.759 8000.118 9671.917 6512.042 20544.935 7339.215 25938.951
686 687 688 689 690 691 692 693 694 695
1 18916.997 5739.668 24148.609 10114.184 6270.281 8444.772 15014.853 20241.985 6986.577 9350.308
696 697 698 699 700 701 702 703 704 705 706
1 6370.314 5778.851 7415.756 15951.153 23707.796 6657.28 22841.683 6042.712 7577.917 7559.824 7282.556
707 708 709 710 711 712 713 714 715 716 717
1 7849.29 7234.512 20313.452 16904.903 18052.809 20946.05 7402.473 8595.82 15443.250 6134.323 12448.530
718 719 720 721 722 723 724 725 726 727 728
1 6016.094 12349.97 15538.208 18763.215 22902.550 7235.707 20376.123 22537.997 7670.666 21699.782 17031.021
729 730 731 732 733 734 735 736 737 738
1 7987.058 18497.651 9033.558 7081.253 16760.180 7530.462 22169.475 9181.943 8319.013 6803.437
739 740 741 742 743 744 745 746 747 748 749
1 7750.137 23301.162 20141.764 8044.106 10092.12 20073.460 7594.073 5735.451 18446.38 21711.83 22853.889
750 751 752 753 754 755 756 757 758 759 760
1 5765.257 7706.59 6865.483 11261.51 21624.197 7048.932 6066.367 19116.76 6935.36 9671.917 15440.276
761 762 763 764 765 766 767 768 769 770 771
1 8725.237 13093.82 8021.45 21390.784 8614.105 8956.365 20848.203 5906.325 8401.386 14100.53 17128.673
772 773 774 775 776 777 778 779 780 781 782
1 6463.571 18578.152 14064.721 7383.713 7736.566 12885.414 6730.118 10746.04 20060.649 12393.736 7461.579
783 784 785 786 787 788 789 790 791 792 793
1 8232.442 18195.12 6270.883 7471.342 7462.31 8671.805 7150.006 31599.93 8122.057 11405.18 18491.47
794 795 796 797 798 799 800 801 802 803 804
1 6080.537 20238.483 12800.389 10505.166 9744.564 21519.266 13309.212 6089.509 22566.136 14125.118 30068.71
805 806 807 808 809 810 811 812 813 814
1 15813.636 16360.419 20590.218 21579.710 7299.075 7952.828 16427.697 13487.874 6217.515 16283.170
815 816 817 818 819 820 821 822 823 824 825
1 17526.429 11036.419 18552.040 8346.816 13575.827 23854.46 6000.504 6342.692 14002.499 6946.358 7459.623
826 827 828 829 830 831 832 833 834 835 836
1 12047.956 8721.242 14509.42 12047.956 10013.559 7896.491 15312.692 6816.668 14083.484 22157.634 20532.218
837 838 839 840 841 842 843 844 845 846 847
1 6169.666 29802.68 17103.741 21452.413 7297.15 13889.851 23048.655 17375.504 24454.540 7441.771 19257.994
848 849 850 851 852 853 854 855 856 857 858
1 14159.373 24497.248 20779.730 19502.940 12502.060 14660.828 19698.252 18619.456 6781.83 8403.617 7656.399
859 860 861 862 863 864 865 866 867 868
1 22303.069 16338.041 12357.887 17465.504 18986.047 10126.011 19097.343 7610.896 18962.744 6967.569
869 870 871 872 873 874 875 876 877 878
1 5945.824 7750.137 25585.253 5934.088 13280.960 6575.935 8081.039 24786.378 24170.378 7692.262
879 880 881 882 883 884 885 886 887 888 889
1 7931.331 16755.935 20540.179 25339.857 7957.858 11086.07 26207.668 17540.342 8813.144 9207.459 26769.99
890 891 892 893 894 895 896 897 898 899
1 7750.137 7676.634 6153.474 16303.767 14867.999 7692.473 7066.477 8947.304 16138.446 18183.375
900 901 902 903 904 905 906 907 908 909
1 8452.655 14978.220 6625.605 7699.875 6148.773 23739.982 5964.229 17465.504 13818.694 24865.684
910 911 912 913 914 915 916 917 918 919 920
1 7760.838 19534.806 14266.159 18621.176 6016.962 9261.599 7024.662 21556.588 7913.102 21902.262 7516.46
921 922 923 924 925 926 927 928 929 930 931
1 6297.41 13818.694 24395.756 6490.817 8907.691 25863.132 6490.817 21414.853 25038.182 18641.973 6621.385
932 933 934 935 936 937 938 939 940 941 942
1 6997.648 8345.479 5954.756 6669.551 13724.479 15035.347 23342.080 14281.905 10796.21 15312.692 16087.193
943 944 945 946 947 948 949 950 951 952 953
1 16037.372 7164.585 7751.031 25462.586 25411.94 6017.871 5984.147 7342.925 6745.943 7750.137 5842.859
954 955 956 957 958 959 960 961 962 963
1 20076.582 8232.011 21752.418 23206.571 23206.571 8123.366 22082.939 14078.702 14078.702 6703.129
964 965 966 967 968 969 970 971 972 973 974
1 13542.709 15539.237 11638.259 6012.346 18419.292 6316.663 8799.242 15892.029 7035.613 7556.606 11510.11
975 976 977 978 979 980 981 982 983 984 985
1 17774.55 6341.14 14284.284 18177.317 11934.21 10909.067 6653.194 9282.774 6305.798 8603.725 10256.80
986 987 988 989 990 991 992 993 994 995
1 8546.546 15543.331 23887.695 7252.058 15159.185 18716.542 9605.808 20854.357 21346.596 6621.651
996 997 998 999 1000
1 6397.754 25516.34 10351.00 16261.720 5812.89
[ reached getOption("max.print") -- omitted 1 row ]
Clustering vector:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
2 1 2 1 1 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 1 2 1 2 1 1 1 2 1 2 1 1 1 2 1 2 1 2 2 1 2
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
1 2 1 1 2 2 2 1 1 1 1 2 2 1 1 1 1 1 2 2 1 2
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
1 2 1 1 1 2 2 1 1 2 1 1 1 2 1 2 2 2 1 1 2 2
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
1 1 2 1 1 1 2 2 2 1 1 2 2 1 1 1 1 2 1 2 2 2
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
2 2 1 2 1 1 1 1 2 1 1 2 1 2 1 2 1 1 1 2 2 1
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 1 2 2 1 1 1 2
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 2 2 1 2 1 2
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
2 2 2 2 1 1 2 1 2 1 1 1 2 1 1 2 1 2 2 1 2 1
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 1
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
1 1 1 1 2 1 1 1 2 1 2 2 2 1 1 2 1 1 1 1 1 2
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
1 1 2 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 1 1
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
1 1 1 1 2 2 2 1 1 1 2 1 2 1 2 1 1 1 1 2 2 1
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
1 2 2 1 1 1 1 2 2 1 1 2 2 1 1 2 2 1 2 1 1 2
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 1 2 2 1 1 1 1
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
1 1 2 1 2 1 1 1 2 1 2 2 1 2 2 2 1 1 2 1 1 1
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
2 2 2 2 1 1 2 2 2 2 1 1 1 1 2 1 2 1 2 1 1 1
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
1 1 1 2 1 1 1 1 2 2 1 1 2 1 2 1 1 1 2 1 2 1
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 2 1 2 2 2 1 1
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
1 2 1 1 2 2 1 2 1 1 1 2 1 1 1 1 1 2 1 2 1 1
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
2 1 1 2 1 2 2 2 2 2 1 2 2 2 1 1 2 1 1 1 2 2
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
2 1 1 1 2 1 2 1 1 2 1 2 2 2 2 1 1 2 2 1 2 2
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
2 2 2 1 1 1 1 2 1 2 2 2 2 1 2 2 2 2 2 1 1 1
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
1 1 1 1 1 2 1 1 1 2 1 1 1 2 2 1 2 2 2 2 1 1
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
2 2 1 1 2 1 1 2 1 2 2 2 1 2 2 2 1 1 2 1 2 2
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
2 1 1 1 1 1 1 2 2 1 2 1 1 2 1 1 1 1 1 2 2 1
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
2 1 1 1 1 1 2 1 2 1 2 2 2 2 1 1 1 1 2 2 1 2
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
2 1 2 2 1 2 2 2 1 1 1 1 1 1 2 2 1 2 1 1 2 2
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
2 1 2 1 1 2 2 2 2 2 2 2 1 2 2 1 2 2 1 2 1 2
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
1 1 1 1 1 2 2 2 1 2 2 1 2 1 1 2 2 1 1 2 2 1
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
2 2 1 1 1 1 2 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
2 1 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 2 1 2 1 1
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
1 1 1 1 2 2 2 2 1 1 2 1 2 1 1 2 2 2 1 2 2 1
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
2 2 1 2 1 1 2 1 2 1 1 1 1 2 2 1 1 2 1 1 2 2
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
2 1 2 2 1 1 2 1 1 2 2 1 1 2 1 1 1 1 1 2 1 1
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
2 1 2 2 2 1 2 2 1 2 2 2 2 2 2 2 1 1 2 2 1 2
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
2 2 2 1 2 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 2 2
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
1 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 1 1
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
2 2 2 2 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902
2 2 1 1 2 2 1 1 2 1 1 1 2 2 1 1 1 2 2 1 2 1
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
1 1 2 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 1 2 2 1
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946
1 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 2 2 2 1 1 2
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
2 1 1 1 1 1 1 2 1 2 2 2 1 2 2 2 1 2 2 2 1 2
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990
1 1 2 1 1 1 2 1 2 2 1 2 1 1 1 1 1 1 2 2 1 2
991 992 993 994 995 996 997 998 999 1000
2 1 2 2 1 1 2 1 2 1
Within cluster sum of squares by cluster:
[1] 1.033989e+13 7.293884e+12
(between_SS / total_SS = 65.9 %)
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss" "size"
[8] "iter" "ifault"
#print(km$withinss)